package com.linwen.excise.niuke._20;

import java.util.Scanner;

/**
 * @author wlw
 * @date 2023/3/1 10:34 PM
 */
public class _5进制转换 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        char[] chars = str.toCharArray();
        int result = 0;
        int count = 1;
        for (int i = chars.length - 1; i >= 2; i--) {
            if(chars[i]=='A'){
                result += count*10;
            }
            else if(chars[i]=='B'){
                result += count*11;
            }
            else if(chars[i]=='C'){
                result += count*12;
            }
            else if(chars[i]=='D'){
                result += count*13;
            }
            else if(chars[i]=='E'){
                result += count*14;
            }
            else if(chars[i]=='F'){
                result += count*15;
            }
            else{
                result += count*Integer.parseInt(String.valueOf(chars[i]));
            }


            count *= 16;
        }
        System.out.println(result);
    }
}
